package logic

import (
	"8-dshop/api/internal/utils"
	"8-dshop/shoprpc/shoprpc"
	"context"

	"8-dshop/api/internal/svc"
	"8-dshop/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CarDelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCarDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CarDelLogic {
	return &CarDelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CarDelLogic) CarDel(req *types.CarDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	del, err := l.svcCtx.ShopRpc.CarDel(l.ctx, &shoprpc.CarDelRequest{
		UserId:    req.UserId,
		ProductId: req.ProductId,
	})
	if err != nil {
		return utils.ReturnResponse(err.Error(), 0, nil)
	}
	return utils.ReturnResponse("购物车删除成功", 200, del)

}
